//
//  HeroFighter.cpp
//  FruitCrush
//
//  Created by wuliqing on 15/8/12.
//
//

#include "HeroFighter.h"
static HeroFighter *mHeroFighter = nullptr;

HeroFighter* HeroFighter::getInstance()
{
    if (!mHeroFighter)
    {
    	mHeroFighter = new HeroFighter();
    }

    return mHeroFighter;
}

HeroFighter::HeroFighter()
{
	healthLevelValue = UserDefault::getInstance()->getIntegerForKey("healthLevelValue-Fighter");
	healthValue = HEALTH_BASE + healthLevelValue * HEALTH_CEAL;
	swordLevelValue = UserDefault::getInstance()->getIntegerForKey("swordLevelValue-Fighter");
	swordValue = ATTACK_BASE + swordLevelValue * ATTACK_CEAL;
	fireLevelValue = UserDefault::getInstance()->getIntegerForKey("fireLevelValue-Fighter");
	fireValue = ATTACK_BASE + fireLevelValue * ATTACK_CEAL;
	arrowLevelValue = UserDefault::getInstance()->getIntegerForKey("arrowLevelValue-Fighter");
	arrowValue = ATTACK_BASE + arrowLevelValue * ATTACK_CEAL;
	lightLevelValue = UserDefault::getInstance()->getIntegerForKey("lightLevelValue-Fighter");
	lightValue = ATTACK_BASE + lightLevelValue * ATTACK_CEAL;

	healthGlodValue = UserDefault::getInstance()->getIntegerForKey("healthGlodValue-Fighter",GLOD_CEAL);
	swordGlodValue = UserDefault::getInstance()->getIntegerForKey("swordGlodValue-Fighter",GLOD_CEAL);
	fireGlodValue = UserDefault::getInstance()->getIntegerForKey("fireGlodValue-Fighter",GLOD_CEAL);
	arrowGlodValue = UserDefault::getInstance()->getIntegerForKey("arrowGlodValue-Fighter",GLOD_CEAL);
	lightGlodValue = UserDefault::getInstance()->getIntegerForKey("lightGlodValue-Fighter",GLOD_CEAL);
}

HeroFighter::~HeroFighter(void)
{
	mHeroFighter = nullptr;
}

void HeroFighter::setArrowLevelValue(int var){
	int value = UserDefault::getInstance()->getIntegerForKey("arrowLevelValue-Fighter");
	UserDefault::getInstance()->setIntegerForKey("arrowLevelValue-Fighter", value + 1);
	arrowLevelValue = UserDefault::getInstance()->getIntegerForKey("arrowLevelValue-Fighter");
	arrowValue = ATTACK_BASE + arrowLevelValue * ATTACK_CEAL;
}
void HeroFighter::setFireLevelValue(int var){
	int value = UserDefault::getInstance()->getIntegerForKey("fireLevelValue-Fighter");
	UserDefault::getInstance()->setIntegerForKey("fireLevelValue-Fighter", value + 1);
	fireLevelValue = UserDefault::getInstance()->getIntegerForKey("fireLevelValue-Fighter");
	fireValue = ATTACK_BASE + fireLevelValue * ATTACK_CEAL;
}
void HeroFighter::setHealthLevelValue(int var){
	int value = UserDefault::getInstance()->getIntegerForKey("healthLevelValue-Fighter");
	UserDefault::getInstance()->setIntegerForKey("healthLevelValue-Fighter", value + 1);
	healthLevelValue = UserDefault::getInstance()->getIntegerForKey("healthLevelValue-Fighter");
	healthValue = HEALTH_BASE + healthLevelValue * HEALTH_CEAL;
}
void HeroFighter::setLightLevelValue(int var){
	int value = UserDefault::getInstance()->getIntegerForKey("lightLevelValue-Fighter");
	UserDefault::getInstance()->setIntegerForKey("lightLevelValue-Fighter", value + 1);
	lightLevelValue = UserDefault::getInstance()->getIntegerForKey("lightLevelValue-Fighter");
	lightValue = ATTACK_BASE + lightLevelValue * ATTACK_CEAL;
}
void HeroFighter::setSwordLevelValue(int var){
	int value = UserDefault::getInstance()->getIntegerForKey("swordLevelValue-Fighter");
	UserDefault::getInstance()->setIntegerForKey("swordLevelValue-Fighter", value + 1);
	swordLevelValue = UserDefault::getInstance()->getIntegerForKey("swordLevelValue-Fighter");
	swordValue = ATTACK_BASE + swordLevelValue * ATTACK_CEAL;
}
void HeroFighter::setHealthGlodValue(int var){
	int value = UserDefault::getInstance()->getIntegerForKey("healthGlodValue-Fighter",GLOD_CEAL);
	UserDefault::getInstance()->setIntegerForKey("healthGlodValue-Fighter", value + GLOD_CEAL);
	healthGlodValue = value + GLOD_CEAL;
}
void HeroFighter::setSwordGlodValue(int var){
	int value = UserDefault::getInstance()->getIntegerForKey("swordGlodValue-Fighter",GLOD_CEAL);
	UserDefault::getInstance()->setIntegerForKey("swordGlodValue-Fighter", value + GLOD_CEAL);
	swordGlodValue = value + GLOD_CEAL;
}
void HeroFighter::setFireGlodValue(int var){
	int value = UserDefault::getInstance()->getIntegerForKey("fireGlodValue-Fighter",GLOD_CEAL);
	UserDefault::getInstance()->setIntegerForKey("fireGlodValue-Fighter", value + GLOD_CEAL);
	fireGlodValue = value + GLOD_CEAL;
}
void HeroFighter::setArrowGlodValue(int var){
	int value = UserDefault::getInstance()->getIntegerForKey("arrowGlodValue-Fighter",GLOD_CEAL);
	UserDefault::getInstance()->setIntegerForKey("arrowGlodValue-Fighter", value + GLOD_CEAL);
	arrowGlodValue = value + GLOD_CEAL;
}
void HeroFighter::setLightGlodValue(int var){
	int value = UserDefault::getInstance()->getIntegerForKey("lightGlodValue-Fighter",GLOD_CEAL);
	UserDefault::getInstance()->setIntegerForKey("lightGlodValue-Fighter", value + GLOD_CEAL);
	lightGlodValue = value + GLOD_CEAL;
}

